package com.zzedu.controller;

import com.zzedu.common.annotation.Log;
import com.zzedu.common.core.controller.BaseController;
import com.zzedu.common.core.domain.AjaxResult;
import com.zzedu.common.core.page.TableDataInfo;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.utils.ServletUtils;
import com.zzedu.common.utils.poi.ExcelUtil;
import com.zzedu.domain.ZzClassesSendStudent;
import com.zzedu.dto.ZzClassesSendStudentDTO;
import com.zzedu.service.IZzClassesSendStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 班级课程解锁记录Controller
 * 
 * @author Mr.Wang
 * @date 2025-08-30
 */
@RestController
@RequestMapping("/school/classessendstudent")
public class ZzClassesSendStudentController extends BaseController
{
    @Autowired
    private IZzClassesSendStudentService zzClassesSendStudentService;

    /**
     * 查询班级课程解锁记录列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendstudent:query')")
    @RequestMapping("/list")
    public TableDataInfo list(@RequestBody ZzClassesSendStudentDTO zzClassesSendStudent)
    {
        return getDataTable(zzClassesSendStudentService.page(zzClassesSendStudent.getPageDTO(),zzClassesSendStudentService.buildQuery(zzClassesSendStudent)));
    }

    /**
     * 导出班级课程解锁记录列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendstudent:export')")
    @Log(title = "班级课程解锁记录", businessType = BusinessType.EXPORT)
    @RequestMapping("/export")
    public void export(ZzClassesSendStudentDTO zzClassesSendStudent)
    {
        List<ZzClassesSendStudent> list = zzClassesSendStudentService.list(zzClassesSendStudentService.buildQuery(zzClassesSendStudent));
        ExcelUtil<ZzClassesSendStudent> util = new ExcelUtil<ZzClassesSendStudent>(ZzClassesSendStudent.class);
        util.exportExcel(ServletUtils.getResponse(),list, "班级课程解锁记录数据");
    }




    /**
     * 新增保存班级课程解锁记录
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendstudent:add')")
    @Log(title = "班级课程解锁记录", businessType = BusinessType.INSERT)
    @RequestMapping("/add")
    public AjaxResult addSave(@Validated @RequestBody ZzClassesSendStudent zzClassesSendStudent)
    {
        return toAjax(zzClassesSendStudentService.save(zzClassesSendStudent));
    }



    /**
     * 获取班级课程解锁记录详细信息
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendstudent:query')")
    @RequestMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zzClassesSendStudentService.getById(id));
    }


    /**
     * 修改保存班级课程解锁记录
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendstudent:edit')")
    @Log(title = "班级课程解锁记录", businessType = BusinessType.UPDATE)
    @RequestMapping("/edit")
    public AjaxResult editSave(@Validated @RequestBody ZzClassesSendStudent zzClassesSendStudent)
    {
        return toAjax(zzClassesSendStudentService.updateById(zzClassesSendStudent));
    }

    /**
     * 删除班级课程解锁记录
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendstudent:remove')")
    @Log(title = "班级课程解锁记录", businessType = BusinessType.DELETE)
	@RequestMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(zzClassesSendStudentService.removeBatchByIds(ids));
    }
}
